<?php

namespace app\admin\controller\weixin;

use app\common\controller\AdminController;
use EasyAdmin\annotation\ControllerAnnotation;
use EasyAdmin\annotation\NodeAnotation;
use think\App;

/**
 * @ControllerAnnotation(title="微信用户管理")
 */
class User extends AdminController
{

    use \app\admin\traits\Curd;

    public function __construct(App $app)
    {
        parent::__construct($app);

        $this->model = new \app\common\model\WeixinUser();

        $this->assign('getTypeList', $this->model->getTypeList());

        $this->assign('getStatusList', $this->model->getStatusList());

    }

    /**
     * @NodeAnotation(title="查看报表")
     * @param $id
     * @return void
     * @throws \think\Exception
     */
    public function open($id)
    {
        //查询
        $row = $this->model->getBaseById($id);
        if (empty($row)) {
            $this->error("不存在");
        }
        $res = $this->model->updateDataSave($row['id'], [
            'is_web' => $row['is_web'] == 1 ? 0 : 1,
            "update_time" => time()
        ]);
        if ($res) {
            $this->success("设置成功");
        } else {
            $this->error("设置失败");
        }
    }
}